package com.itheima.threadDemo;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

public class Demo5 {
    public static void main(String[] args) {
        //优先级问题,先创建对象
        MC mc1 = new MC();
        //创建FutureTask对象,
        FutureTask<String> ft1 = new FutureTask<>(mc1);
        Thread t1 = new Thread(ft1);
        t1.setPriority(10);//优先级
        t1.setName("小明");
        t1.start();


        MC mc2 = new MC();
        FutureTask<String> ft2 = new FutureTask<>(mc2);
        Thread t2 = new Thread(ft2);
        t2.setPriority(1);//优先级
        t2.setName("小强");
        t2.start();
    }
}

class MC implements Callable<String> {
    @Override
    public String call() throws Exception {
        for (int i = 0; i < 50; i++) {
            System.out.println(Thread.currentThread().getName() + "启动了" + i);
        }
        return "ok";
    }
}